package cn.drenal.capcap.mapper;

import cn.drenal.capcap.entity.Activity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * 活动Mapper接口
 */
@Mapper
public interface ActivityMapper extends BaseMapper<Activity> {
    
    /**
     * 获取指定月份的活动数量
     *
     * @param startDate 开始日期
     * @param endDate 结束日期
     * @return 活动数量
     */
    @Select("SELECT COUNT(*) FROM activity WHERE create_time >= #{startDate} AND create_time < #{endDate}")
    long countActivitiesByDateRange(String startDate, String endDate);
    
    /**
     * 获取活动的作品数量
     *
     * @param activityId 活动ID
     * @return 作品数量
     */
    @Select("SELECT COUNT(*) FROM artwork WHERE activity_id = #{activityId}")
    int countArtworksByActivity(Long activityId);
    
    /**
     * 获取活动的参与用户数量
     *
     * @param activityId 活动ID
     * @return 参与用户数量
     */
    @Select("SELECT COUNT(DISTINCT user_id) FROM artwork WHERE activity_id = #{activityId}")
    int countParticipantsByActivity(Long activityId);
}